<?php
	/**
	 * The abstract TablePointOutGen class defined here is
	 * code-generated and contains all the basic CRUD-type functionality as well as
	 * basic methods to handle relationships and index-based loading.
	 *
	 * To use, you should use the TablePointOut subclass which
	 * extends this TablePointOutGen class.
	 *
	 * Because subsequent re-code generations will overwrite any changes to this
	 * file, you should leave this file unaltered to prevent yourself from losing
	 * any information or code changes.  All customizations should be done by
	 * overriding existing or implementing new methods, properties and variables
	 * in the TablePointOut class.
	 * 
	 * @package My Application
	 * @subpackage GeneratedDataObjects
	 * @property-read integer $Id the value for intId (Read-Only PK)
	 * @property integer $UserId the value for intUserId (Not Null)
	 * @property integer $Currency the value for intCurrency 
	 * @property integer $PointBalanceBefore the value for intPointBalanceBefore (Not Null)
	 * @property integer $PointBalanceAfter the value for intPointBalanceAfter (Not Null)
	 * @property integer $PointOut the value for intPointOut (Not Null)
	 * @property QDateTime $OutDate the value for dttOutDate 
	 * @property string $Description the value for strDescription 
	 * @property string $Active the value for strActive (Not Null)
	 * @property integer $Status the value for intStatus (Not Null)
	 * @property TableUserProject $User the value for the TableUserProject object referenced by intUserId (Not Null)
	 * @property-read TableTransaction $_TableTransactionAsPointOut the value for the private _objTableTransactionAsPointOut (Read-Only) if set due to an expansion on the table_transaction.point_out_id reverse relationship
	 * @property-read TableTransaction[] $_TableTransactionAsPointOutArray the value for the private _objTableTransactionAsPointOutArray (Read-Only) if set due to an ExpandAsArray on the table_transaction.point_out_id reverse relationship
	 * @property-read boolean $__Restored whether or not this object was restored from the database (as opposed to created new)
	 */
	class TablePointOutGen extends QBaseClass {

		///////////////////////////////////////////////////////////////////////
		// PROTECTED MEMBER VARIABLES and TEXT FIELD MAXLENGTHS (if applicable)
		///////////////////////////////////////////////////////////////////////
		
		/**
		 * Protected member variable that maps to the database PK Identity column table_point_out.id
		 * @var integer intId
		 */
		protected $intId;
		const IdDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_point_out.user_id
		 * @var integer intUserId
		 */
		protected $intUserId;
		const UserIdDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_point_out.currency
		 * @var integer intCurrency
		 */
		protected $intCurrency;
		const CurrencyDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_point_out.point_balance_before
		 * @var integer intPointBalanceBefore
		 */
		protected $intPointBalanceBefore;
		const PointBalanceBeforeDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_point_out.point_balance_after
		 * @var integer intPointBalanceAfter
		 */
		protected $intPointBalanceAfter;
		const PointBalanceAfterDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_point_out.point_out
		 * @var integer intPointOut
		 */
		protected $intPointOut;
		const PointOutDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_point_out.out_date
		 * @var QDateTime dttOutDate
		 */
		protected $dttOutDate;
		const OutDateDefault = null;


		/**
		 * Protected member variable that maps to the database column table_point_out.description
		 * @var string strDescription
		 */
		protected $strDescription;
		const DescriptionMaxLength = 200;
		const DescriptionDefault = null;


		/**
		 * Protected member variable that maps to the database column table_point_out.active
		 * @var string strActive
		 */
		protected $strActive;
		const ActiveMaxLength = 1;
		const ActiveDefault = null;


		/**
		 * Protected member variable that maps to the database column table_point_out.status
		 * @var integer intStatus
		 */
		protected $intStatus;
		const StatusDefault = 0;


		/**
		 * Private member variable that stores a reference to a single TableTransactionAsPointOut object
		 * (of type TableTransaction), if this TablePointOut object was restored with
		 * an expansion on the table_transaction association table.
		 * @var TableTransaction _objTableTransactionAsPointOut;
		 */
		private $_objTableTransactionAsPointOut;

		/**
		 * Private member variable that stores a reference to an array of TableTransactionAsPointOut objects
		 * (of type TableTransaction[]), if this TablePointOut object was restored with
		 * an ExpandAsArray on the table_transaction association table.
		 * @var TableTransaction[] _objTableTransactionAsPointOutArray;
		 */
		private $_objTableTransactionAsPointOutArray = array();

		/**
		 * Protected array of virtual attributes for this object (e.g. extra/other calculated and/or non-object bound
		 * columns from the run-time database query result for this object).  Used by InstantiateDbRow and
		 * GetVirtualAttribute.
		 * @var string[] $__strVirtualAttributeArray
		 */
		protected $__strVirtualAttributeArray = array();

		/**
		 * Protected internal member variable that specifies whether or not this object is Restored from the database.
		 * Used by Save() to determine if Save() should perform a db UPDATE or INSERT.
		 * @var bool __blnRestored;
		 */
		protected $__blnRestored;




		///////////////////////////////
		// PROTECTED MEMBER OBJECTS
		///////////////////////////////

		/**
		 * Protected member variable that contains the object pointed by the reference
		 * in the database column table_point_out.user_id.
		 *
		 * NOTE: Always use the User property getter to correctly retrieve this TableUserProject object.
		 * (Because this class implements late binding, this variable reference MAY be null.)
		 * @var TableUserProject objUser
		 */
		protected $objUser;





		///////////////////////////////
		// CLASS-WIDE LOAD AND COUNT METHODS
		///////////////////////////////

		/**
		 * Static method to retrieve the Database object that owns this class.
		 * @return QDatabaseBase reference to the Database object that can query this class
		 */
		public static function GetDatabase() {
			return QApplication::$Database[1];
		}

		/**
		 * Load a TablePointOut from PK Info
		 * @param integer $intId
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TablePointOut
		 */
		public static function Load($intId, $objOptionalClauses = null) {
			// Use QuerySingle to Perform the Query
			return TablePointOut::QuerySingle(
				QQ::AndCondition(
					QQ::Equal(QQN::TablePointOut()->Id, $intId)
				),
				$objOptionalClauses
			);
		}

		/**
		 * Load all TablePointOuts
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TablePointOut[]
		 */
		public static function LoadAll($objOptionalClauses = null) {
			if (func_num_args() > 1) {
				throw new QCallerException("LoadAll must be called with an array of optional clauses as a single argument");
			}
			// Call TablePointOut::QueryArray to perform the LoadAll query
			try {
				return TablePointOut::QueryArray(QQ::All(), $objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count all TablePointOuts
		 * @return int
		 */
		public static function CountAll() {
			// Call TablePointOut::QueryCount to perform the CountAll query
			return TablePointOut::QueryCount(QQ::All());
		}




		///////////////////////////////
		// QCUBED QUERY-RELATED METHODS
		///////////////////////////////

		/**
		 * Internally called method to assist with calling Qcubed Query for this class
		 * on load methods.
		 * @param QQueryBuilder &$objQueryBuilder the QueryBuilder object that will be created
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause object or array of QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with (sending in null will skip the PrepareStatement step)
		 * @param boolean $blnCountOnly only select a rowcount
		 * @return string the query statement
		 */
		protected static function BuildQueryStatement(&$objQueryBuilder, QQCondition $objConditions, $objOptionalClauses, $mixParameterArray, $blnCountOnly) {
			// Get the Database Object for this Class
			$objDatabase = TablePointOut::GetDatabase();

			// Create/Build out the QueryBuilder object with TablePointOut-specific SELET and FROM fields
			$objQueryBuilder = new QQueryBuilder($objDatabase, 'table_point_out');
			TablePointOut::GetSelectFields($objQueryBuilder);
			$objQueryBuilder->AddFromItem('table_point_out');

			// Set "CountOnly" option (if applicable)
			if ($blnCountOnly)
				$objQueryBuilder->SetCountOnlyFlag();

			// Apply Any Conditions
			if ($objConditions)
				try {
					$objConditions->UpdateQueryBuilder($objQueryBuilder);
				} catch (QCallerException $objExc) {
					$objExc->IncrementOffset();
					throw $objExc;
				}

			// Iterate through all the Optional Clauses (if any) and perform accordingly
			if ($objOptionalClauses) {
				if ($objOptionalClauses instanceof QQClause)
					$objOptionalClauses->UpdateQueryBuilder($objQueryBuilder);
				else if (is_array($objOptionalClauses))
					foreach ($objOptionalClauses as $objClause)
						$objClause->UpdateQueryBuilder($objQueryBuilder);
				else
					throw new QCallerException('Optional Clauses must be a QQClause object or an array of QQClause objects');
			}

			// Get the SQL Statement
			$strQuery = $objQueryBuilder->GetStatement();

			// Prepare the Statement with the Query Parameters (if applicable)
			if ($mixParameterArray) {
				if (is_array($mixParameterArray)) {
					if (count($mixParameterArray))
						$strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);

					// Ensure that there are no other Unresolved Named Parameters
					if (strpos($strQuery, chr(QQNamedValue::DelimiterCode) . '{') !== false)
						throw new QCallerException('Unresolved named parameters in the query');
				} else
					throw new QCallerException('Parameter Array must be an array of name-value parameter pairs');
			}

			// Return the Objects
			return $strQuery;
		}

		/**
		 * Static Qcubed Query method to query for a single TablePointOut object.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return TablePointOut the queried object
		 */
		public static function QuerySingle(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = TablePointOut::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
			
			// Perform the Query, Get the First Row, and Instantiate a new TablePointOut object
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);
			
			// Do we have to expand anything?
			if ($objQueryBuilder->ExpandAsArrayNodes) {
				$objToReturn = array();
				while ($objDbRow = $objDbResult->GetNextRow()) {
					$objItem = TablePointOut::InstantiateDbRow($objDbRow, null, $objQueryBuilder->ExpandAsArrayNodes, $objToReturn, $objQueryBuilder->ColumnAliasArray);
					if ($objItem)
						$objToReturn[] = $objItem;					
				}			
				// Since we only want the object to return, lets return the object and not the array.
				return $objToReturn[0];
			} else {
				// No expands just return the first row
				$objToReturn = null;
				while ($objDbRow = $objDbResult->GetNextRow())
					$objToReturn = TablePointOut::InstantiateDbRow($objDbRow, null, null, null, $objQueryBuilder->ColumnAliasArray);
			}
			
			return $objToReturn;
		}

		/**
		 * Static Qcubed Query method to query for an array of TablePointOut objects.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return TablePointOut[] the queried objects as an array
		 */
		public static function QueryArray(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = TablePointOut::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Perform the Query and Instantiate the Array Result
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);
			return TablePointOut::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
		}

		/**
		 * Static Qcubed Query method to query for a count of TablePointOut objects.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return integer the count of queried objects as an integer
		 */
		public static function QueryCount(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = TablePointOut::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, true);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Perform the Query and return the row_count
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);

			// Figure out if the query is using GroupBy
			$blnGrouped = false;

			if ($objOptionalClauses) foreach ($objOptionalClauses as $objClause) {
				if ($objClause instanceof QQGroupBy) {
					$blnGrouped = true;
					break;
				}
			}

			if ($blnGrouped)
				// Groups in this query - return the count of Groups (which is the count of all rows)
				return $objDbResult->CountRows();
			else {
				// No Groups - return the sql-calculated count(*) value
				$strDbRow = $objDbResult->FetchRow();
				return QType::Cast($strDbRow[0], QType::Integer);
			}
		}

		public static function QueryArrayCached(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null, $blnForceUpdate = false) {
			// Get the Database Object for this Class
			$objDatabase = TablePointOut::GetDatabase();

			$strQuery = TablePointOut::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
			
			$objCache = new QCache('qquery/tablepointout', $strQuery);
			$cacheData = $objCache->GetData();
			
			if (!$cacheData || $blnForceUpdate) {
				$objDbResult = $objQueryBuilder->Database->Query($strQuery);
				$arrResult = TablePointOut::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
				$objCache->SaveData(serialize($arrResult));
			} else {
				$arrResult = unserialize($cacheData);
			}
			
			return $arrResult;
		}

		/**
		 * Updates a QQueryBuilder with the SELECT fields for this TablePointOut
		 * @param QQueryBuilder $objBuilder the Query Builder object to update
		 * @param string $strPrefix optional prefix to add to the SELECT fields
		 */
		public static function GetSelectFields(QQueryBuilder $objBuilder, $strPrefix = null) {
			if ($strPrefix) {
				$strTableName = $strPrefix;
				$strAliasPrefix = $strPrefix . '__';
			} else {
				$strTableName = 'table_point_out';
				$strAliasPrefix = '';
			}

			$objBuilder->AddSelectItem($strTableName, 'id', $strAliasPrefix . 'id');
			$objBuilder->AddSelectItem($strTableName, 'user_id', $strAliasPrefix . 'user_id');
			$objBuilder->AddSelectItem($strTableName, 'currency', $strAliasPrefix . 'currency');
			$objBuilder->AddSelectItem($strTableName, 'point_balance_before', $strAliasPrefix . 'point_balance_before');
			$objBuilder->AddSelectItem($strTableName, 'point_balance_after', $strAliasPrefix . 'point_balance_after');
			$objBuilder->AddSelectItem($strTableName, 'point_out', $strAliasPrefix . 'point_out');
			$objBuilder->AddSelectItem($strTableName, 'out_date', $strAliasPrefix . 'out_date');
			$objBuilder->AddSelectItem($strTableName, 'description', $strAliasPrefix . 'description');
			$objBuilder->AddSelectItem($strTableName, 'active', $strAliasPrefix . 'active');
			$objBuilder->AddSelectItem($strTableName, 'status', $strAliasPrefix . 'status');
		}



		///////////////////////////////
		// INSTANTIATION-RELATED METHODS
		///////////////////////////////

		/**
		 * Instantiate a TablePointOut from a Database Row.
		 * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
		 * is calling this TablePointOut::InstantiateDbRow in order to perform
		 * early binding on referenced objects.
		 * @param DatabaseRowBase $objDbRow
		 * @param string $strAliasPrefix
		 * @param string $strExpandAsArrayNodes
		 * @param QBaseClass $arrPreviousItem
		 * @param string[] $strColumnAliasArray
		 * @return TablePointOut
		*/
		public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $arrPreviousItems = null, $strColumnAliasArray = array()) {
			// If blank row, return null
			if (!$objDbRow) {
				return null;
			}
			// See if we're doing an array expansion on the previous item
			$strAlias = $strAliasPrefix . 'id';
			$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
			if (($strExpandAsArrayNodes) && is_array($arrPreviousItems) && count($arrPreviousItems)) {
				foreach ($arrPreviousItems as $objPreviousItem) {            
					if ($objPreviousItem->intId == $objDbRow->GetColumn($strAliasName, 'Integer')) {        
						// We are.  Now, prepare to check for ExpandAsArray clauses
						$blnExpandedViaArray = false;
						if (!$strAliasPrefix)
							$strAliasPrefix = 'table_point_out__';


						// Expanding reverse references: TableTransactionAsPointOut
						$strAlias = $strAliasPrefix . 'tabletransactionaspointout__id';
						$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
						if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
							(!is_null($objDbRow->GetColumn($strAliasName)))) {
							if ($intPreviousChildItemCount = count($objPreviousItem->_objTableTransactionAsPointOutArray)) {
								$objPreviousChildItems = $objPreviousItem->_objTableTransactionAsPointOutArray;
								$objChildItem = TableTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'tabletransactionaspointout__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
								if ($objChildItem) {
									$objPreviousItem->_objTableTransactionAsPointOutArray[] = $objChildItem;
								}
							} else {
								$objPreviousItem->_objTableTransactionAsPointOutArray[] = TableTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'tabletransactionaspointout__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
							}
							$blnExpandedViaArray = true;
						}

						// Either return false to signal array expansion, or check-to-reset the Alias prefix and move on
						if ($blnExpandedViaArray) {
							return false;
						} else if ($strAliasPrefix == 'table_point_out__') {
							$strAliasPrefix = null;
						}
					}
				}
			}

			// Create a new instance of the TablePointOut object
			$objToReturn = new TablePointOut();
			$objToReturn->__blnRestored = true;

			$strAliasName = array_key_exists($strAliasPrefix . 'id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'id'] : $strAliasPrefix . 'id';
			$objToReturn->intId = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'user_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'user_id'] : $strAliasPrefix . 'user_id';
			$objToReturn->intUserId = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'currency', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'currency'] : $strAliasPrefix . 'currency';
			$objToReturn->intCurrency = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'point_balance_before', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'point_balance_before'] : $strAliasPrefix . 'point_balance_before';
			$objToReturn->intPointBalanceBefore = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'point_balance_after', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'point_balance_after'] : $strAliasPrefix . 'point_balance_after';
			$objToReturn->intPointBalanceAfter = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'point_out', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'point_out'] : $strAliasPrefix . 'point_out';
			$objToReturn->intPointOut = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'out_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'out_date'] : $strAliasPrefix . 'out_date';
			$objToReturn->dttOutDate = $objDbRow->GetColumn($strAliasName, 'DateTime');
			$strAliasName = array_key_exists($strAliasPrefix . 'description', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'description'] : $strAliasPrefix . 'description';
			$objToReturn->strDescription = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'active', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'active'] : $strAliasPrefix . 'active';
			$objToReturn->strActive = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'status', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'status'] : $strAliasPrefix . 'status';
			$objToReturn->intStatus = $objDbRow->GetColumn($strAliasName, 'Integer');

			if (isset($arrPreviousItems) && is_array($arrPreviousItems)) {
				foreach ($arrPreviousItems as $objPreviousItem) {
					if ($objToReturn->Id != $objPreviousItem->Id) {
						continue;
					}
					if (array_diff($objPreviousItem->_objTableTransactionAsPointOutArray, $objToReturn->_objTableTransactionAsPointOutArray) != null) {
						continue;
					}

					// complete match - all primary key columns are the same
					return null;
				}
			}

			// Instantiate Virtual Attributes
			foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
				$strVirtualPrefix = $strAliasPrefix . '__';
				$strVirtualPrefixLength = strlen($strVirtualPrefix);
				if (substr($strColumnName, 0, $strVirtualPrefixLength) == $strVirtualPrefix)
					$objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
			}

			// Prepare to Check for Early/Virtual Binding
			if (!$strAliasPrefix)
				$strAliasPrefix = 'table_point_out__';

			// Check for User Early Binding
			$strAlias = $strAliasPrefix . 'user_id__id';
			$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
			if (!is_null($objDbRow->GetColumn($strAliasName)))
				$objToReturn->objUser = TableUserProject::InstantiateDbRow($objDbRow, $strAliasPrefix . 'user_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);




			// Check for TableTransactionAsPointOut Virtual Binding
			$strAlias = $strAliasPrefix . 'tabletransactionaspointout__id';
			$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
			if (!is_null($objDbRow->GetColumn($strAliasName))) {
				if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
					$objToReturn->_objTableTransactionAsPointOutArray[] = TableTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'tabletransactionaspointout__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
				else
					$objToReturn->_objTableTransactionAsPointOut = TableTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'tabletransactionaspointout__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
			}

			return $objToReturn;
		}

		/**
		 * Instantiate an array of TablePointOuts from a Database Result
		 * @param DatabaseResultBase $objDbResult
		 * @param string $strExpandAsArrayNodes
		 * @param string[] $strColumnAliasArray
		 * @return TablePointOut[]
		 */
		public static function InstantiateDbResult(QDatabaseResultBase $objDbResult, $strExpandAsArrayNodes = null, $strColumnAliasArray = null) {
			$objToReturn = array();
			
			if (!$strColumnAliasArray)
				$strColumnAliasArray = array();

			// If blank resultset, then return empty array
			if (!$objDbResult)
				return $objToReturn;

			// Load up the return array with each row
			if ($strExpandAsArrayNodes) {
				$objToReturn = array();
				while ($objDbRow = $objDbResult->GetNextRow()) {
					$objItem = TablePointOut::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objToReturn, $strColumnAliasArray);
					if ($objItem) {
						$objToReturn[] = $objItem;
					}
				}
			} else {
				while ($objDbRow = $objDbResult->GetNextRow())
					$objToReturn[] = TablePointOut::InstantiateDbRow($objDbRow, null, null, null, $strColumnAliasArray);
			}

			return $objToReturn;
		}



		///////////////////////////////////////////////////
		// INDEX-BASED LOAD METHODS (Single Load and Array)
		///////////////////////////////////////////////////
			
		/**
		 * Load a single TablePointOut object,
		 * by Id Index(es)
		 * @param integer $intId
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TablePointOut
		*/
		public static function LoadById($intId, $objOptionalClauses = null) {
			return TablePointOut::QuerySingle(
				QQ::AndCondition(
					QQ::Equal(QQN::TablePointOut()->Id, $intId)
				),
				$objOptionalClauses
			);
		}
			
		/**
		 * Load an array of TablePointOut objects,
		 * by UserId Index(es)
		 * @param integer $intUserId
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TablePointOut[]
		*/
		public static function LoadArrayByUserId($intUserId, $objOptionalClauses = null) {
			// Call TablePointOut::QueryArray to perform the LoadArrayByUserId query
			try {
				return TablePointOut::QueryArray(
					QQ::Equal(QQN::TablePointOut()->UserId, $intUserId),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TablePointOuts
		 * by UserId Index(es)
		 * @param integer $intUserId
		 * @return int
		*/
		public static function CountByUserId($intUserId) {
			// Call TablePointOut::QueryCount to perform the CountByUserId query
			return TablePointOut::QueryCount(
				QQ::Equal(QQN::TablePointOut()->UserId, $intUserId)
			);
		}
			
		/**
		 * Load an array of TablePointOut objects,
		 * by Currency Index(es)
		 * @param integer $intCurrency
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TablePointOut[]
		*/
		public static function LoadArrayByCurrency($intCurrency, $objOptionalClauses = null) {
			// Call TablePointOut::QueryArray to perform the LoadArrayByCurrency query
			try {
				return TablePointOut::QueryArray(
					QQ::Equal(QQN::TablePointOut()->Currency, $intCurrency),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TablePointOuts
		 * by Currency Index(es)
		 * @param integer $intCurrency
		 * @return int
		*/
		public static function CountByCurrency($intCurrency) {
			// Call TablePointOut::QueryCount to perform the CountByCurrency query
			return TablePointOut::QueryCount(
				QQ::Equal(QQN::TablePointOut()->Currency, $intCurrency)
			);
		}
			
		/**
		 * Load an array of TablePointOut objects,
		 * by PointBalanceBefore Index(es)
		 * @param integer $intPointBalanceBefore
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TablePointOut[]
		*/
		public static function LoadArrayByPointBalanceBefore($intPointBalanceBefore, $objOptionalClauses = null) {
			// Call TablePointOut::QueryArray to perform the LoadArrayByPointBalanceBefore query
			try {
				return TablePointOut::QueryArray(
					QQ::Equal(QQN::TablePointOut()->PointBalanceBefore, $intPointBalanceBefore),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TablePointOuts
		 * by PointBalanceBefore Index(es)
		 * @param integer $intPointBalanceBefore
		 * @return int
		*/
		public static function CountByPointBalanceBefore($intPointBalanceBefore) {
			// Call TablePointOut::QueryCount to perform the CountByPointBalanceBefore query
			return TablePointOut::QueryCount(
				QQ::Equal(QQN::TablePointOut()->PointBalanceBefore, $intPointBalanceBefore)
			);
		}
			
		/**
		 * Load an array of TablePointOut objects,
		 * by PointBalanceAfter Index(es)
		 * @param integer $intPointBalanceAfter
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TablePointOut[]
		*/
		public static function LoadArrayByPointBalanceAfter($intPointBalanceAfter, $objOptionalClauses = null) {
			// Call TablePointOut::QueryArray to perform the LoadArrayByPointBalanceAfter query
			try {
				return TablePointOut::QueryArray(
					QQ::Equal(QQN::TablePointOut()->PointBalanceAfter, $intPointBalanceAfter),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TablePointOuts
		 * by PointBalanceAfter Index(es)
		 * @param integer $intPointBalanceAfter
		 * @return int
		*/
		public static function CountByPointBalanceAfter($intPointBalanceAfter) {
			// Call TablePointOut::QueryCount to perform the CountByPointBalanceAfter query
			return TablePointOut::QueryCount(
				QQ::Equal(QQN::TablePointOut()->PointBalanceAfter, $intPointBalanceAfter)
			);
		}
			
		/**
		 * Load an array of TablePointOut objects,
		 * by PointOut Index(es)
		 * @param integer $intPointOut
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TablePointOut[]
		*/
		public static function LoadArrayByPointOut($intPointOut, $objOptionalClauses = null) {
			// Call TablePointOut::QueryArray to perform the LoadArrayByPointOut query
			try {
				return TablePointOut::QueryArray(
					QQ::Equal(QQN::TablePointOut()->PointOut, $intPointOut),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TablePointOuts
		 * by PointOut Index(es)
		 * @param integer $intPointOut
		 * @return int
		*/
		public static function CountByPointOut($intPointOut) {
			// Call TablePointOut::QueryCount to perform the CountByPointOut query
			return TablePointOut::QueryCount(
				QQ::Equal(QQN::TablePointOut()->PointOut, $intPointOut)
			);
		}
			
		/**
		 * Load an array of TablePointOut objects,
		 * by OutDate Index(es)
		 * @param QDateTime $dttOutDate
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TablePointOut[]
		*/
		public static function LoadArrayByOutDate($dttOutDate, $objOptionalClauses = null) {
			// Call TablePointOut::QueryArray to perform the LoadArrayByOutDate query
			try {
				return TablePointOut::QueryArray(
					QQ::Equal(QQN::TablePointOut()->OutDate, $dttOutDate),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TablePointOuts
		 * by OutDate Index(es)
		 * @param QDateTime $dttOutDate
		 * @return int
		*/
		public static function CountByOutDate($dttOutDate) {
			// Call TablePointOut::QueryCount to perform the CountByOutDate query
			return TablePointOut::QueryCount(
				QQ::Equal(QQN::TablePointOut()->OutDate, $dttOutDate)
			);
		}
			
		/**
		 * Load an array of TablePointOut objects,
		 * by Active Index(es)
		 * @param string $strActive
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TablePointOut[]
		*/
		public static function LoadArrayByActive($strActive, $objOptionalClauses = null) {
			// Call TablePointOut::QueryArray to perform the LoadArrayByActive query
			try {
				return TablePointOut::QueryArray(
					QQ::Equal(QQN::TablePointOut()->Active, $strActive),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TablePointOuts
		 * by Active Index(es)
		 * @param string $strActive
		 * @return int
		*/
		public static function CountByActive($strActive) {
			// Call TablePointOut::QueryCount to perform the CountByActive query
			return TablePointOut::QueryCount(
				QQ::Equal(QQN::TablePointOut()->Active, $strActive)
			);
		}



		////////////////////////////////////////////////////
		// INDEX-BASED LOAD METHODS (Array via Many to Many)
		////////////////////////////////////////////////////




		//////////////////////////
		// SAVE, DELETE AND RELOAD
		//////////////////////////

		/**
		 * Save this TablePointOut
		 * @param bool $blnForceInsert
		 * @param bool $blnForceUpdate
		 * @return int
		 */
		public function Save($blnForceInsert = false, $blnForceUpdate = false) {
			// Get the Database Object for this Class
			$objDatabase = TablePointOut::GetDatabase();

			$mixToReturn = null;

			try {
				if ((!$this->__blnRestored) || ($blnForceInsert)) {
					// Perform an INSERT query
					$objDatabase->NonQuery('
						INSERT INTO `table_point_out` (
							`user_id`,
							`currency`,
							`point_balance_before`,
							`point_balance_after`,
							`point_out`,
							`out_date`,
							`description`,
							`active`,
							`status`
						) VALUES (
							' . $objDatabase->SqlVariable($this->intUserId) . ',
							' . $objDatabase->SqlVariable($this->intCurrency) . ',
							' . $objDatabase->SqlVariable($this->intPointBalanceBefore) . ',
							' . $objDatabase->SqlVariable($this->intPointBalanceAfter) . ',
							' . $objDatabase->SqlVariable($this->intPointOut) . ',
							' . $objDatabase->SqlVariable($this->dttOutDate) . ',
							' . $objDatabase->SqlVariable($this->strDescription) . ',
							' . $objDatabase->SqlVariable($this->strActive) . ',
							' . $objDatabase->SqlVariable($this->intStatus) . '
						)
					');

					// Update Identity column and return its value
					$mixToReturn = $this->intId = $objDatabase->InsertId('table_point_out', 'id');
				} else {
					// Perform an UPDATE query

					// First checking for Optimistic Locking constraints (if applicable)

					// Perform the UPDATE query
					$objDatabase->NonQuery('
						UPDATE
							`table_point_out`
						SET
							`user_id` = ' . $objDatabase->SqlVariable($this->intUserId) . ',
							`currency` = ' . $objDatabase->SqlVariable($this->intCurrency) . ',
							`point_balance_before` = ' . $objDatabase->SqlVariable($this->intPointBalanceBefore) . ',
							`point_balance_after` = ' . $objDatabase->SqlVariable($this->intPointBalanceAfter) . ',
							`point_out` = ' . $objDatabase->SqlVariable($this->intPointOut) . ',
							`out_date` = ' . $objDatabase->SqlVariable($this->dttOutDate) . ',
							`description` = ' . $objDatabase->SqlVariable($this->strDescription) . ',
							`active` = ' . $objDatabase->SqlVariable($this->strActive) . ',
							`status` = ' . $objDatabase->SqlVariable($this->intStatus) . '
						WHERE
							`id` = ' . $objDatabase->SqlVariable($this->intId) . '
					');
				}

			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Update __blnRestored and any Non-Identity PK Columns (if applicable)
			$this->__blnRestored = true;


			// Return 
			return $mixToReturn;
		}

		/**
		 * Delete this TablePointOut
		 * @return void
		 */
		public function Delete() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Cannot delete this TablePointOut with an unset primary key.');

			// Get the Database Object for this Class
			$objDatabase = TablePointOut::GetDatabase();


			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`table_point_out`
				WHERE
					`id` = ' . $objDatabase->SqlVariable($this->intId) . '');
		}

		/**
		 * Delete all TablePointOuts
		 * @return void
		 */
		public static function DeleteAll() {
			// Get the Database Object for this Class
			$objDatabase = TablePointOut::GetDatabase();

			// Perform the Query
			$objDatabase->NonQuery('
				DELETE FROM
					`table_point_out`');
		}

		/**
		 * Truncate table_point_out table
		 * @return void
		 */
		public static function Truncate() {
			// Get the Database Object for this Class
			$objDatabase = TablePointOut::GetDatabase();

			// Perform the Query
			$objDatabase->NonQuery('
				TRUNCATE `table_point_out`');
		}

		/**
		 * Reload this TablePointOut from the database.
		 * @return void
		 */
		public function Reload() {
			// Make sure we are actually Restored from the database
			if (!$this->__blnRestored)
				throw new QCallerException('Cannot call Reload() on a new, unsaved TablePointOut object.');

			// Reload the Object
			$objReloaded = TablePointOut::Load($this->intId);

			// Update $this's local variables to match
			$this->UserId = $objReloaded->UserId;
			$this->intCurrency = $objReloaded->intCurrency;
			$this->intPointBalanceBefore = $objReloaded->intPointBalanceBefore;
			$this->intPointBalanceAfter = $objReloaded->intPointBalanceAfter;
			$this->intPointOut = $objReloaded->intPointOut;
			$this->dttOutDate = $objReloaded->dttOutDate;
			$this->strDescription = $objReloaded->strDescription;
			$this->strActive = $objReloaded->strActive;
			$this->intStatus = $objReloaded->intStatus;
		}



		////////////////////
		// PUBLIC OVERRIDERS
		////////////////////

				/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				///////////////////
				// Member Variables
				///////////////////
				case 'Id':
					/**
					 * Gets the value for intId (Read-Only PK)
					 * @return integer
					 */
					return $this->intId;

				case 'UserId':
					/**
					 * Gets the value for intUserId (Not Null)
					 * @return integer
					 */
					return $this->intUserId;

				case 'Currency':
					/**
					 * Gets the value for intCurrency 
					 * @return integer
					 */
					return $this->intCurrency;

				case 'PointBalanceBefore':
					/**
					 * Gets the value for intPointBalanceBefore (Not Null)
					 * @return integer
					 */
					return $this->intPointBalanceBefore;

				case 'PointBalanceAfter':
					/**
					 * Gets the value for intPointBalanceAfter (Not Null)
					 * @return integer
					 */
					return $this->intPointBalanceAfter;

				case 'PointOut':
					/**
					 * Gets the value for intPointOut (Not Null)
					 * @return integer
					 */
					return $this->intPointOut;

				case 'OutDate':
					/**
					 * Gets the value for dttOutDate 
					 * @return QDateTime
					 */
					return $this->dttOutDate;

				case 'Description':
					/**
					 * Gets the value for strDescription 
					 * @return string
					 */
					return $this->strDescription;

				case 'Active':
					/**
					 * Gets the value for strActive (Not Null)
					 * @return string
					 */
					return $this->strActive;

				case 'Status':
					/**
					 * Gets the value for intStatus (Not Null)
					 * @return integer
					 */
					return $this->intStatus;


				///////////////////
				// Member Objects
				///////////////////
				case 'User':
					/**
					 * Gets the value for the TableUserProject object referenced by intUserId (Not Null)
					 * @return TableUserProject
					 */
					try {
						if ((!$this->objUser) && (!is_null($this->intUserId)))
							$this->objUser = TableUserProject::Load($this->intUserId);
						return $this->objUser;
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}


				////////////////////////////
				// Virtual Object References (Many to Many and Reverse References)
				// (If restored via a "Many-to" expansion)
				////////////////////////////

				case '_TableTransactionAsPointOut':
					/**
					 * Gets the value for the private _objTableTransactionAsPointOut (Read-Only)
					 * if set due to an expansion on the table_transaction.point_out_id reverse relationship
					 * @return TableTransaction
					 */
					return $this->_objTableTransactionAsPointOut;

				case '_TableTransactionAsPointOutArray':
					/**
					 * Gets the value for the private _objTableTransactionAsPointOutArray (Read-Only)
					 * if set due to an ExpandAsArray on the table_transaction.point_out_id reverse relationship
					 * @return TableTransaction[]
					 */
					return (array) $this->_objTableTransactionAsPointOutArray;


				case '__Restored':
					return $this->__blnRestored;

				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

				/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			switch ($strName) {
				///////////////////
				// Member Variables
				///////////////////
				case 'UserId':
					/**
					 * Sets the value for intUserId (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						$this->objUser = null;
						return ($this->intUserId = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Currency':
					/**
					 * Sets the value for intCurrency 
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intCurrency = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'PointBalanceBefore':
					/**
					 * Sets the value for intPointBalanceBefore (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intPointBalanceBefore = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'PointBalanceAfter':
					/**
					 * Sets the value for intPointBalanceAfter (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intPointBalanceAfter = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'PointOut':
					/**
					 * Sets the value for intPointOut (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intPointOut = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'OutDate':
					/**
					 * Sets the value for dttOutDate 
					 * @param QDateTime $mixValue
					 * @return QDateTime
					 */
					try {
						return ($this->dttOutDate = QType::Cast($mixValue, QType::DateTime));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Description':
					/**
					 * Sets the value for strDescription 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strDescription = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Active':
					/**
					 * Sets the value for strActive (Not Null)
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strActive = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Status':
					/**
					 * Sets the value for intStatus (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intStatus = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}


				///////////////////
				// Member Objects
				///////////////////
				case 'User':
					/**
					 * Sets the value for the TableUserProject object referenced by intUserId (Not Null)
					 * @param TableUserProject $mixValue
					 * @return TableUserProject
					 */
					if (is_null($mixValue)) {
						$this->intUserId = null;
						$this->objUser = null;
						return null;
					} else {
						// Make sure $mixValue actually is a TableUserProject object
						try {
							$mixValue = QType::Cast($mixValue, 'TableUserProject');
						} catch (QInvalidCastException $objExc) {
							$objExc->IncrementOffset();
							throw $objExc;
						} 

						// Make sure $mixValue is a SAVED TableUserProject object
						if (is_null($mixValue->Id))
							throw new QCallerException('Unable to set an unsaved User for this TablePointOut');

						// Update Local Member Variables
						$this->objUser = $mixValue;
						$this->intUserId = $mixValue->Id;

						// Return $mixValue
						return $mixValue;
					}
					break;

				default:
					try {
						return parent::__set($strName, $mixValue);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Lookup a VirtualAttribute value (if applicable).  Returns NULL if none found.
		 * @param string $strName
		 * @return string
		 */
		public function GetVirtualAttribute($strName) {
			if (array_key_exists($strName, $this->__strVirtualAttributeArray))
				return $this->__strVirtualAttributeArray[$strName];
			return null;
		}



		///////////////////////////////
		// ASSOCIATED OBJECTS' METHODS
		///////////////////////////////

			
		
		// Related Objects' Methods for TableTransactionAsPointOut
		//-------------------------------------------------------------------

		/**
		 * Gets all associated TableTransactionsAsPointOut as an array of TableTransaction objects
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableTransaction[]
		*/ 
		public function GetTableTransactionAsPointOutArray($objOptionalClauses = null) {
			if ((is_null($this->intId)))
				return array();

			try {
				return TableTransaction::LoadArrayByPointOutId($this->intId, $objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Counts all associated TableTransactionsAsPointOut
		 * @return int
		*/ 
		public function CountTableTransactionsAsPointOut() {
			if ((is_null($this->intId)))
				return 0;

			return TableTransaction::CountByPointOutId($this->intId);
		}

		/**
		 * Associates a TableTransactionAsPointOut
		 * @param TableTransaction $objTableTransaction
		 * @return void
		*/ 
		public function AssociateTableTransactionAsPointOut(TableTransaction $objTableTransaction) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call AssociateTableTransactionAsPointOut on this unsaved TablePointOut.');
			if ((is_null($objTableTransaction->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call AssociateTableTransactionAsPointOut on this TablePointOut with an unsaved TableTransaction.');

			// Get the Database Object for this Class
			$objDatabase = TablePointOut::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`table_transaction`
				SET
					`point_out_id` = ' . $objDatabase->SqlVariable($this->intId) . '
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objTableTransaction->Id) . '
			');
		}

		/**
		 * Unassociates a TableTransactionAsPointOut
		 * @param TableTransaction $objTableTransaction
		 * @return void
		*/ 
		public function UnassociateTableTransactionAsPointOut(TableTransaction $objTableTransaction) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTableTransactionAsPointOut on this unsaved TablePointOut.');
			if ((is_null($objTableTransaction->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTableTransactionAsPointOut on this TablePointOut with an unsaved TableTransaction.');

			// Get the Database Object for this Class
			$objDatabase = TablePointOut::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`table_transaction`
				SET
					`point_out_id` = null
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objTableTransaction->Id) . ' AND
					`point_out_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Unassociates all TableTransactionsAsPointOut
		 * @return void
		*/ 
		public function UnassociateAllTableTransactionsAsPointOut() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTableTransactionAsPointOut on this unsaved TablePointOut.');

			// Get the Database Object for this Class
			$objDatabase = TablePointOut::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`table_transaction`
				SET
					`point_out_id` = null
				WHERE
					`point_out_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Deletes an associated TableTransactionAsPointOut
		 * @param TableTransaction $objTableTransaction
		 * @return void
		*/ 
		public function DeleteAssociatedTableTransactionAsPointOut(TableTransaction $objTableTransaction) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTableTransactionAsPointOut on this unsaved TablePointOut.');
			if ((is_null($objTableTransaction->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTableTransactionAsPointOut on this TablePointOut with an unsaved TableTransaction.');

			// Get the Database Object for this Class
			$objDatabase = TablePointOut::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`table_transaction`
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objTableTransaction->Id) . ' AND
					`point_out_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Deletes all associated TableTransactionsAsPointOut
		 * @return void
		*/ 
		public function DeleteAllTableTransactionsAsPointOut() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTableTransactionAsPointOut on this unsaved TablePointOut.');

			// Get the Database Object for this Class
			$objDatabase = TablePointOut::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`table_transaction`
				WHERE
					`point_out_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}





		////////////////////////////////////////
		// METHODS for SOAP-BASED WEB SERVICES
		////////////////////////////////////////

		public static function GetSoapComplexTypeXml() {
			$strToReturn = '<complexType name="TablePointOut"><sequence>';
			$strToReturn .= '<element name="Id" type="xsd:int"/>';
			$strToReturn .= '<element name="User" type="xsd1:TableUserProject"/>';
			$strToReturn .= '<element name="Currency" type="xsd:int"/>';
			$strToReturn .= '<element name="PointBalanceBefore" type="xsd:int"/>';
			$strToReturn .= '<element name="PointBalanceAfter" type="xsd:int"/>';
			$strToReturn .= '<element name="PointOut" type="xsd:int"/>';
			$strToReturn .= '<element name="OutDate" type="xsd:dateTime"/>';
			$strToReturn .= '<element name="Description" type="xsd:string"/>';
			$strToReturn .= '<element name="Active" type="xsd:string"/>';
			$strToReturn .= '<element name="Status" type="xsd:int"/>';
			$strToReturn .= '<element name="__blnRestored" type="xsd:boolean"/>';
			$strToReturn .= '</sequence></complexType>';
			return $strToReturn;
		}

		public static function AlterSoapComplexTypeArray(&$strComplexTypeArray) {
			if (!array_key_exists('TablePointOut', $strComplexTypeArray)) {
				$strComplexTypeArray['TablePointOut'] = TablePointOut::GetSoapComplexTypeXml();
				TableUserProject::AlterSoapComplexTypeArray($strComplexTypeArray);
			}
		}

		public static function GetArrayFromSoapArray($objSoapArray) {
			$objArrayToReturn = array();

			foreach ($objSoapArray as $objSoapObject)
				array_push($objArrayToReturn, TablePointOut::GetObjectFromSoapObject($objSoapObject));

			return $objArrayToReturn;
		}

		public static function GetObjectFromSoapObject($objSoapObject) {
			$objToReturn = new TablePointOut();
			if (property_exists($objSoapObject, 'Id'))
				$objToReturn->intId = $objSoapObject->Id;
			if ((property_exists($objSoapObject, 'User')) &&
				($objSoapObject->User))
				$objToReturn->User = TableUserProject::GetObjectFromSoapObject($objSoapObject->User);
			if (property_exists($objSoapObject, 'Currency'))
				$objToReturn->intCurrency = $objSoapObject->Currency;
			if (property_exists($objSoapObject, 'PointBalanceBefore'))
				$objToReturn->intPointBalanceBefore = $objSoapObject->PointBalanceBefore;
			if (property_exists($objSoapObject, 'PointBalanceAfter'))
				$objToReturn->intPointBalanceAfter = $objSoapObject->PointBalanceAfter;
			if (property_exists($objSoapObject, 'PointOut'))
				$objToReturn->intPointOut = $objSoapObject->PointOut;
			if (property_exists($objSoapObject, 'OutDate'))
				$objToReturn->dttOutDate = new QDateTime($objSoapObject->OutDate);
			if (property_exists($objSoapObject, 'Description'))
				$objToReturn->strDescription = $objSoapObject->Description;
			if (property_exists($objSoapObject, 'Active'))
				$objToReturn->strActive = $objSoapObject->Active;
			if (property_exists($objSoapObject, 'Status'))
				$objToReturn->intStatus = $objSoapObject->Status;
			if (property_exists($objSoapObject, '__blnRestored'))
				$objToReturn->__blnRestored = $objSoapObject->__blnRestored;
			return $objToReturn;
		}

		public static function GetSoapArrayFromArray($objArray) {
			if (!$objArray)
				return null;

			$objArrayToReturn = array();

			foreach ($objArray as $objObject)
				array_push($objArrayToReturn, TablePointOut::GetSoapObjectFromObject($objObject, true));

			return unserialize(serialize($objArrayToReturn));
		}

		public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) {
			if ($objObject->objUser)
				$objObject->objUser = TableUserProject::GetSoapObjectFromObject($objObject->objUser, false);
			else if (!$blnBindRelatedObjects)
				$objObject->intUserId = null;
			if ($objObject->dttOutDate)
				$objObject->dttOutDate = $objObject->dttOutDate->__toString(QDateTime::FormatSoap);
			return $objObject;
		}




	}



	/////////////////////////////////////
	// ADDITIONAL CLASSES for QCubed QUERY
	/////////////////////////////////////

	class QQNodeTablePointOut extends QQNode {
		protected $strTableName = 'table_point_out';
		protected $strPrimaryKey = 'id';
		protected $strClassName = 'TablePointOut';
		public function __get($strName) {
			switch ($strName) {
				case 'Id':
					return new QQNode('id', 'Id', 'integer', $this);
				case 'UserId':
					return new QQNode('user_id', 'UserId', 'integer', $this);
				case 'User':
					return new QQNodeTableUserProject('user_id', 'User', 'integer', $this);
				case 'Currency':
					return new QQNode('currency', 'Currency', 'integer', $this);
				case 'PointBalanceBefore':
					return new QQNode('point_balance_before', 'PointBalanceBefore', 'integer', $this);
				case 'PointBalanceAfter':
					return new QQNode('point_balance_after', 'PointBalanceAfter', 'integer', $this);
				case 'PointOut':
					return new QQNode('point_out', 'PointOut', 'integer', $this);
				case 'OutDate':
					return new QQNode('out_date', 'OutDate', 'QDateTime', $this);
				case 'Description':
					return new QQNode('description', 'Description', 'string', $this);
				case 'Active':
					return new QQNode('active', 'Active', 'string', $this);
				case 'Status':
					return new QQNode('status', 'Status', 'integer', $this);
				case 'TableTransactionAsPointOut':
					return new QQReverseReferenceNodeTableTransaction($this, 'tabletransactionaspointout', 'reverse_reference', 'point_out_id');

				case '_PrimaryKeyNode':
					return new QQNode('id', 'Id', 'integer', $this);
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}
	}

	class QQReverseReferenceNodeTablePointOut extends QQReverseReferenceNode {
		protected $strTableName = 'table_point_out';
		protected $strPrimaryKey = 'id';
		protected $strClassName = 'TablePointOut';
		public function __get($strName) {
			switch ($strName) {
				case 'Id':
					return new QQNode('id', 'Id', 'integer', $this);
				case 'UserId':
					return new QQNode('user_id', 'UserId', 'integer', $this);
				case 'User':
					return new QQNodeTableUserProject('user_id', 'User', 'integer', $this);
				case 'Currency':
					return new QQNode('currency', 'Currency', 'integer', $this);
				case 'PointBalanceBefore':
					return new QQNode('point_balance_before', 'PointBalanceBefore', 'integer', $this);
				case 'PointBalanceAfter':
					return new QQNode('point_balance_after', 'PointBalanceAfter', 'integer', $this);
				case 'PointOut':
					return new QQNode('point_out', 'PointOut', 'integer', $this);
				case 'OutDate':
					return new QQNode('out_date', 'OutDate', 'QDateTime', $this);
				case 'Description':
					return new QQNode('description', 'Description', 'string', $this);
				case 'Active':
					return new QQNode('active', 'Active', 'string', $this);
				case 'Status':
					return new QQNode('status', 'Status', 'integer', $this);
				case 'TableTransactionAsPointOut':
					return new QQReverseReferenceNodeTableTransaction($this, 'tabletransactionaspointout', 'reverse_reference', 'point_out_id');

				case '_PrimaryKeyNode':
					return new QQNode('id', 'Id', 'integer', $this);
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}
	}

?>